package com.itheima.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.pojo.CheckGroup;
import com.itheima.vo.CheckGroupVo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface CheckGroupMapper extends BaseMapper<CheckGroup> {

    //中间表插入数据
    @Insert("insert into t_checkgroup_checkitem values(#{group},#{checkItemId})")
    void addCheckGroupAndCheckItemIds(@Param("groupId") Integer groupId,@Param("checkItemId") int checkItemId);


    @Select("select g.* from t_setmeal_group t left join t_checkgroup g\n" +
            "on g.id = t.group_id\n" +
            "where  g.delete_flag = 0 and setmeal_id = #{setmealId}")
    List<CheckGroupVo> findBySetmealId(@Param("setmealId") Long setmealId);
}
